package contracts.simpleCodingQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/simpleCodingQuizzes/students/5/assignments/1/quizzes/1")
                , consumer(regex("/api/simpleCodingQuizzes/students/\\d+/assignments/\\d+/quizzes/\\d+"))))
    }
    response {
        status(200)
        body("""
        [{
            "id": 1,
            "description": "sss",
            "evaluateScript": "1542019086473-bee0d2ed-e615-410e-97b7-06d84e3529e8.sh",
            "templateRepository": "https: //github.com/recruiting-system/java-collection-operator-2018-11-12-10-37-55-147.git",
            "makerId": 5,
            "homeworkName": "测试用的题目",
            "stackId": 4,
            "definitionRepo": "https: //github.com/Aceysx/java-collection-operator.git",
            "quizGroupId": 2,
        }]
        """)
        bodyMatchers {
            jsonPath('$[*]', byType())
            jsonPath('$[*].id', byRegex(number()))
            jsonPath('$[*].description', byRegex("[\\S\\s]+"))
            jsonPath('$[*].evaluateScript', byRegex("[\\S\\s]+"))
            jsonPath('$[*].templateRepository', byRegex("[\\S\\s]+"))
            jsonPath('$[*].makerId', byRegex(number()))
            jsonPath('$[*].homeworkName', byRegex("[\\S\\s]+"))
            jsonPath('$[*].stackId', byRegex(number()))
            jsonPath('$[*].definitionRepo', byRegex("[\\S\\s]+"))
            jsonPath('$[*].quizGroupId', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
